TARGET	= dbproxy
OUTDIR	= $(OUTPUTDIR)
OBJDIR	= $(BUILDDIR)/dbproxy

SRCS	= $(wildcard *.cc)
OBJS	= $(patsubst %.cc, $(OBJDIR)/%.o, $(SRCS))
DIRS	= $(BUILDDIR) $(BUILDDIR)/dbproxy
LIBS	= -Wl,--as-needed -Wl,-rpath,. -lnet -lengine -lprotobuf -lmysql

all: prebuild build

prebuild:
	@echo -e '\033[35m=== Start build $(TARGET) ...\033[0m'
	@test -d '$(DIRS)' | mkdir -p $(DIRS)

build: $(OBJS)
	@echo -e '\033[36mGenerate $(OUTDIR)/$(TARGET) ... \033[0m'
	@$(CXX) $(CXXFLAGS) -o $(OUTDIR)/$(TARGET) $(OBJS) $(LDFLAGS) $(LIBS)

clean:
	@rm -f $(OBJS) $(OUTDIR)/$(TARGET)

$(OBJDIR)/%.o: %.cc
	@echo -e '\033[33m--> Compile $< ...\033[0m'
	@$(CXX) $(CXXFLAGS) -c $< -o $@ $(INCLUDES) 
